package nancal.mp.db.mongo.table

import java.io.*
import nbcp.base.db.*
import nbcp.base.comm.*
import nbcp.base.extend.*
import nbcp.base.enums.*
import nbcp.base.utils.*
import nbcp.myoql.db.*
import nbcp.myoql.db.comm.*
import nbcp.myoql.db.enums.*
import nbcp.myoql.db.mongo.*
import nbcp.myoql.db.mongo.base.*
import nbcp.myoql.db.mongo.component.*
import org.slf4j.LoggerFactory
import org.springframework.stereotype.*


@Component("mongo.shop")
@MetaDataGroup(DatabaseEnum.Mongo, "shop")
class ShopGroup : IDataGroup {
    override fun getEntities(): Set<BaseMetaData<out Any>> = setOf(executeCommissionCategory, executeCommissionProduct, logisticsFeeSet, monthStaticsData, orderInfo, partnerConfig, productFavorite, productInfo, shopActivityInfo, shopCouponInfo, shoppingCart, storeFavorite, themeInfo, userCouponInfo)



    val executeCommissionCategory get() = ExecuteCommissionCategoryEntity();




    val executeCommissionProduct get() = ExecuteCommissionProductEntity();




    val logisticsFeeSet get() = LogisticsFeeSetEntity();




    val monthStaticsData get() = MonthStaticsDataEntity();




    val orderInfo get() = OrderInfoEntity();




    val partnerConfig get() = PartnerConfigEntity();




    val productFavorite get() = ProductFavoriteEntity();




    val productInfo get() = ProductInfoEntity();




    val shopActivityInfo get() = ShopActivityInfoEntity();




    val shopCouponInfo get() = ShopCouponInfoEntity();




    val shoppingCart get() = ShoppingCartEntity();




    val storeFavorite get() = StoreFavoriteEntity();




    val themeInfo get() = ThemeInfoEntity();




    val userCouponInfo get() = UserCouponInfoEntity();



    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class ExecuteCommissionCategoryEntity(collectionName: String = "executeCommissionCategory") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.ExecuteCommissionCategory>(nancal.mp.db.mongo.entity.shop.ExecuteCommissionCategory::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val categoryPath = IdCodeNameMeta("categoryPath")

        val remark = MongoColumnName("remark")

        val createBy = IdNameMeta("createBy")

        val startAt = MongoColumnName("startAt")

        val endAt = MongoColumnName("endAt")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class ExecuteCommissionProductEntity(collectionName: String = "executeCommissionProduct") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.ExecuteCommissionProduct>(nancal.mp.db.mongo.entity.shop.ExecuteCommissionProduct::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val product = IdNameUrlMeta("product")

        val corp = IdNameMeta("corp")

        val remark = MongoColumnName("remark")

        val createBy = IdNameMeta("createBy")

        val startAt = MongoColumnName("startAt")

        val endAt = MongoColumnName("endAt")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class LogisticsFeeSetEntity(collectionName: String = "logisticsFeeSet") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.LogisticsFeeSet>(nancal.mp.db.mongo.entity.shop.LogisticsFeeSet::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val name = MongoColumnName("name")

        val type = MongoColumnName("type")

        val startNumber = MongoColumnName("startNumber")

        val startPrice = MongoColumnName("startPrice")

        val cities = CodeNameMeta("cities")

        val stepNumber = MongoColumnName("stepNumber")

        val stepPrice = MongoColumnName("stepPrice")

        val corp = IdNameMeta("corp")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class MonthStaticsDataEntity(collectionName: String = "monthStaticsData") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.MonthStaticsData>(nancal.mp.db.mongo.entity.shop.MonthStaticsData::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val year = MongoColumnName("year")

        val month = MongoColumnName("month")

        val score = MongoColumnName("score")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    @nbcp.base.db.annotation.DbEntityIndexes(value = arrayOf(nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""orderCode"""), unique = true)))
    class OrderInfoEntity(collectionName: String = "orderInfo") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.OrderInfo>(nancal.mp.db.mongo.entity.shop.OrderInfo::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val orderCode = MongoColumnName("orderCode")

        val status = MongoColumnName("status")

        val createBy = OpenIdNameMeta("createBy")

        val subOrders = CorpOrderInfoMeta("subOrders")

        val receiveAddress = ReceiveAddressDataInfoMeta("receiveAddress")

        val payInfo = OrderPayInfoMeta("payInfo")

        val coupons = UserCouponInfoMeta("coupons")

        val remark = MongoColumnName("remark")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

        fun queryByOrderCode(orderCode: String): MongoQueryClip<OrderInfoEntity, nancal.mp.db.mongo.entity.shop.OrderInfo> {
            return this.query().where { it.orderCode mongoEquals orderCode }
        }


        fun deleteByOrderCode(orderCode: String): MongoDeleteClip<OrderInfoEntity> {
            return this.delete().where { it.orderCode mongoEquals orderCode }
        }

        fun updateByOrderCode(orderCode: String): MongoUpdateClip<OrderInfoEntity, nancal.mp.db.mongo.entity.shop.OrderInfo> {
            return this.update().where { it.orderCode mongoEquals orderCode }
        }
        
        

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class PartnerConfigEntity(collectionName: String = "partnerConfig") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.PartnerConfig>(nancal.mp.db.mongo.entity.shop.PartnerConfig::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val name = MongoColumnName("name")

        val banner = IdUrlMeta("banner")

        val type = MongoColumnName("type")

        val remark = MongoColumnName("remark")

        val commission = MongoColumnName("commission")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class ProductFavoriteEntity(collectionName: String = "productFavorite") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.ProductFavorite>(nancal.mp.db.mongo.entity.shop.ProductFavorite::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val corp = IdNameMeta("corp")

        val product = ProductCardDataMeta("product")

        val user = IdNameMeta("user")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    @nbcp.myoql.db.comm.DbEntityCascades(value = arrayOf(nbcp.myoql.db.comm.DbEntityCascadeDefine(idField = """brandPath.id""", cascadeField = """brandPath.name""", refEntityClass = nancal.mp.db.mongo.entity.sys.BrandInfo::class), nbcp.myoql.db.comm.DbEntityCascadeDefine(idField = """corpCategoryPath.id""", cascadeField = """corpCategoryPath.name""", refEntityClass = nancal.mp.db.mongo.entity.CorpCategory::class), nbcp.myoql.db.comm.DbEntityCascadeDefine(idField = """categoryPath.id""", cascadeField = """categoryPath.name""", refEntityClass = nancal.mp.db.mongo.entity.sys.CategoryInfo::class), nbcp.myoql.db.comm.DbEntityCascadeDefine(idField = """corp.id""", cascadeField = """corp.name""", refEntityClass = nancal.mp.db.mongo.entity.Corporation::class)))
    @nbcp.myoql.db.comm.RemoveToSysDustbin
    class ProductInfoEntity(collectionName: String = "productInfo") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.ProductInfo>(nancal.mp.db.mongo.entity.shop.ProductInfo::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val name = MongoColumnName("name")

        val slogan = MongoColumnName("slogan")

        val brandPath = IdNameMeta("brandPath")

        val corpCategoryPath = IdNameMeta("corpCategoryPath")

        val categoryPath = IdNameMeta("categoryPath")

        val barCode = MongoColumnName("barCode")

        val parameters = ProductParameterDataMeta("parameters")

        val showImages = IdUrlMeta("showImages")

        val images = IdUrlMeta("images")

        val status = MongoColumnName("status")

        val video = IdUrlMeta("video")

        val detail = MongoColumnName("detail")

        val remark = MongoColumnName("remark")

        val corp = IdNameMeta("corp")

        val isGroupProduct = MongoColumnName("isGroupProduct")

        val subProducts = IdNameMeta("subProducts")

        val logisticsFee = LogisticsFeeSetMeta("logisticsFee")

        val skuDefines = SkuDefineDataMeta("skuDefines")

        val skuStockPrice = ProductSkuStockPriceMeta("skuStockPrice")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class ShopActivityInfoEntity(collectionName: String = "shopActivityInfo") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.ShopActivityInfo>(nancal.mp.db.mongo.entity.shop.ShopActivityInfo::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val code = MongoColumnName("code")

        val type = MongoColumnName("type")

        val detail = MongoColumnName("detail")

        val banner = IdUrlMeta("banner")

        val rule = ShopActivityRuleDataMeta("rule")

        val order = MongoColumnName("order")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class ShopCouponInfoEntity(collectionName: String = "shopCouponInfo") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.ShopCouponInfo>(nancal.mp.db.mongo.entity.shop.ShopCouponInfo::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val type = MongoColumnName("type")

        val until = MongoColumnName("until")

        val discountRate = MongoColumnName("discountRate")

        val discountReduce = MongoColumnName("discountReduce")

        val count = MongoColumnName("count")

        val transformUser = MongoColumnName("transformUser")

        val rule = ShopActivityRuleDataMeta("rule")

        val corp = IdNameMeta("corp")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class ShoppingCartEntity(collectionName: String = "shoppingCart") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.ShoppingCart>(nancal.mp.db.mongo.entity.shop.ShoppingCart::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val product = IdNameMeta("product")

        val skuItemData = MongoColumnName("skuItemData")

        val number = MongoColumnName("number")

        val price = MongoColumnName("price")

        val order = MongoColumnName("order")

        val checked = MongoColumnName("checked")

        val createBy = IdNameMeta("createBy")

        val corp = IdNameMeta("corp")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class StoreFavoriteEntity(collectionName: String = "storeFavorite") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.StoreFavorite>(nancal.mp.db.mongo.entity.shop.StoreFavorite::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val corp = IdNameUrlMeta("corp")

        val user = IdNameMeta("user")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class ThemeInfoEntity(collectionName: String = "themeInfo") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.ThemeInfo>(nancal.mp.db.mongo.entity.shop.ThemeInfo::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val name = MongoColumnName("name")

        val logo = IdUrlMeta("logo")

        val images = IdUrlMeta("images")

        val remark = MongoColumnName("remark")

        val shopSiteVar = MongoColumnName("shopSiteVar")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """shop""")
    class UserCouponInfoEntity(collectionName: String = "userCouponInfo") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.shop.UserCouponInfo>(nancal.mp.db.mongo.entity.shop.UserCouponInfo::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val code = MongoColumnName("code")

        val index = MongoColumnName("index")

        val user = IdNameMeta("user")

        val type = MongoColumnName("type")

        val until = MongoColumnName("until")

        val discountRate = MongoColumnName("discountRate")

        val discountReduce = MongoColumnName("discountReduce")

        val count = MongoColumnName("count")

        val transformUser = MongoColumnName("transformUser")

        val rule = ShopActivityRuleDataMeta("rule")

        val corp = IdNameMeta("corp")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }

}

